import { defineStore } from 'pinia'
import { ref } from 'vue'

export interface ChatMessage {
  type: 'user' | 'bot'
  content: string
  timestamp: number
}

export const useChatStore = defineStore('chat', () => {
  const messages = ref<ChatMessage[]>([
    {
      type: 'bot',
      content: '你好！我是你的智能学习助手，有什么可以帮你的吗？',
      timestamp: Date.now(),
    },
  ])

  function addMessage(message: ChatMessage) {
    messages.value.push(message)
  }

  function clearMessages() {
    messages.value = []
  }

  return {
    messages,
    addMessage,
    clearMessages,
  }
})
